#include <iostream>
#include<vector>
#include<string>
using namespace std;

int main() {
    int n=0;
    cin>>n;
    vector<string>v;
    v.resize(n);
    bool csort=true,lsort=true;
    //初始化
    for(auto& str:v)
    {
        cin>>str;
    }
    //长度排序
    for(int i=1;i<n;i++)
    {
        if(v[i-1].size()>v[i].size())
        {
            lsort=false;
            break;
        }
    }
    //字典序排序
    for(int i=1;i<n;i++)
    {
        if(v[i-1]>v[i])
        {
            csort=false;
            break;
        }
    }
    if(lsort&&csort)
        cout<<"both"<<endl;
    else if(lsort)
        cout<<"lengths"<<endl;
    else if(csort)
        cout<<"lexicographically"<<endl;
    else 
    {
        cout<<"none"<<endl;
    }
    return 0;
}
